package main

import (
	"fmt"
	"strconv"
	"os"
	"bufio"
	"io"
)

func convertToBin(n int) string {
	result := ""
	for ; n > 0; n /= 2 {
		lsb := n % 2
		// strconv.Itoa整型转字符串
		result = strconv.Itoa(lsb) + result

	}
	return result
}

func printFile(filename string) {
	file, e := os.Open(filename)
	if e != nil {
		panic(e)
	}
	scanner := bufio.NewScanner(file)

	for scanner.Scan() {
		fmt.Println(scanner.Text())
	}
}

func printFileContents(reader io.Reader) {
	scanner := bufio.NewScanner(reader)
	for scanner.Scan() {
		fmt.Println(scanner.Text())
	}
}

func forever(a int) {
	//go中没有while
	for a > 2 {
		fmt.Println("abc")
	}

	//死循环
	for {
		fmt.Println("abc")
	}
}

func main() {
	fmt.Println(
		convertToBin(5),
		convertToBin(13),
	)
}
